from sqlalchemy import or_, and_
from sqlalchemy.orm import Session
from module_admin.entity.do.cms_order import CmsOrder
from module_admin.entity.do.cms_order_approve import CmsOrderApprove
from module_admin.entity.vo.cms_order_vo import OrderModel, OrderModelForQuery
from module_admin.enum.state_enum import OrderStateEnum
from utils.time_format_util import object_format_datetime, list_format_datetime


class CmsOrderApproveDao:
    """
    部门管理模块数据库操作层
    """

    @classmethod
    def create_order_approve(cls, db: Session, entity: CmsOrderApprove):
        db.add(entity)
        db.flush()
        db.commit()

    @classmethod
    def get_one_by_order_id(cls, db: Session, order_id: str):
        first = db.query(CmsOrderApprove).filter(CmsOrderApprove.order_id == order_id).first()
        return object_format_datetime(first)
